
Namespace Validation

    Public MustInherit Class BaseValidatorAttribute
        Inherits Attribute

#Region " Declarations "

        Protected _strCustomMessage As String = String.Empty
        Protected _strPropertyFriendlyName As String = String.Empty
        Protected _strRuleSet As String = String.Empty

#End Region

#Region " Properties "

        ''' <summary>
        ''' Developers can specify a custom message that is displayed when the validation rule is broken.  The custom message is displayed first and the normal broken rule is appended to the custom message if provided.
        ''' </summary>
        Public Property CustomMessage() As String
            Get
                Return _strCustomMessage
            End Get
            Set(ByVal Value As String)
                _strCustomMessage = Value
            End Set
        End Property

        ''' <summary>
        ''' When broken rule messages are constructed, the object property name is parsed and a friendly name is created.  If the objec property name would not make a good user friendly property name, then developers can add a PropertyFriendlyName that will be used for constructing broken rule messages.
        ''' </summary>
        Public Property PropertyFriendlyName() As String
            Get
                Return _strPropertyFriendlyName
            End Get
            Set(ByVal Value As String)
                _strPropertyFriendlyName = Value
            End Set
        End Property

        ''' <summary>
        ''' If the RuleSet property is not specified then that rule will always be checked.  If the RuleSet is specified then that rule will only be validated when that RuleSet is active.  If a rule applies to more than one RuleSet, then enter each RuleSet name separated by the pipe symbol.  Example:  RuleSet:="Update|Delete"
        ''' </summary>
        Public Property RuleSet() As String
            Get
                Return _strRuleSet
            End Get
            Set(ByVal Value As String)
                _strRuleSet = Value
            End Set
        End Property

#End Region

#Region " Abstract Methods "

        Public MustOverride Function Create(ByVal strPropertyName As String) As Validator

#End Region

    End Class

End Namespace
